< previous page page_586 next page >

Page 586
9f31265bb40b592b1929e18a47ab28e5.gif
   mstrDefault = strDefault

   ' Get Value
   mstrKeyValue = Space(MAX_VALUE)
   lngRet = GetPrivateProfileString( _
                     mstrSection, _
                     mstrKeyName, _
                     mstrDefault, _
                     mstrKeyValue, _
                     MAX_VALUE, _
                     mstrConfigName)
   If lngRet > 0 Then
      mstrKeyValue = Left$(mstrKeyValue, lngRet)
   Else
      mstrKeyValue = ""
   End If

   KeyGet = mstrKeyValue
End Function
Using the INI Class to Save Data
If you fill in the Key Value text box with a different value and then click the Save W/Class command button in the sample form, youll see that information can be saved back to the INI file. The Click event for this command button instantiates an instance of the INI class. Set the values from the text boxes and then invoke the KeySave() method to retrieve the data. Heres the code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdSaveClass_Click()
   Dim oIni As INI

   Set oIni = New INI
   With oIni
      .ConfigName = Trim$(txtConfig)
      .Section = Trim$(txtSection)
      .KeyName = Trim$(txtKeyName)
      .KeyValue = Trim$(txtKeyValue)
      .KeySave
   End With

 
< previous page page_586 next page >

If you like this book, buy it!